<?php
class PNAjaxSubcategoryModelArray extends PNObjectExArray {
  function PNAjaxSubcategoryModelArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'icarrent_subcategory_model';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';

    $this->_objJoin[]     = array ( 'join_table'  =>  'icarrent_model',
                            'join_field'          =>  array('id', 'name'),
                            'object_field_name'   =>  array('model_id', 'model_name'),
                            'compare_field_table' =>  'model_id',
                            'compare_field_join'  =>  'id');


    $this->_init($init, $where);

  }

  function genSort(){
    return " ORDER BY mod_name ASC";
  }

  function genFilter(){
    $subcategory_id  = FormUtil::getPassedValue ('subcategory_id', false);
    $brand_id  = FormUtil::getPassedValue ('brand_id', false);
    $wheres = array();

    //filter by selector
    if ($subcategory_id && intval($subcategory_id))
      $wheres[] = "smod_subcategory_id ='$subcategory_id'";

    //filter by selector
    if ($brand_id && intval($brand_id))
      $wheres[] = "smod_brand_id ='$brand_id'";



    return implode(' AND ', $wheres) ;
  }

}